Formtastic's rendering of forms can be customized in two ways:

* configuration files
* method options

_This section reviews configuration files._ Configuration files, in combination with Formtastic's "feature  set,":http://wiki.github.com/justinfrench/formtastic/1-about#feature_set can be used to implement form standards and best practices.

There are four files that can be used to configure Formtastic forms: a "YAML":http://ruby-doc.org/core/classes/YAML.html file, two CSS files and one Formtastic config file. By file name and location they are: 

* "config/initializers/formtastic.rb":https://github.com/justinfrench/formtastic/blob/master/lib/generators/templates/formtastic.rb
* "public/stylesheets/formtastic.css":https://github.com/justinfrench/formtastic/blob/master/app/assets/stylesheets/formtastic.css
* "public/stylesheets/formtastic_changes.css":http://github.com/justinfrench/formtastic/blob/master/generators/formtastic/templates/formtastic_changes.css
* "config/locales/en.yml":http://wiki.github.com/justinfrench/formtastic/72-example-enyml or fr.yml or de.yml etc.

After "installing the Formtastic gem":http://wiki.github.com/justinfrench/formtastic/2-installation it is recommended that you run @./script/generate formtastic@ to copy the first three files listed above into your application.

h4. Formtastic Form Defaults

The formtastic.rb file is used to override Formtastic's SemanticFormBuilder class variables that set form default attributes. For example, Formtastic uses a class variable to set a default line height for textarea inputs:      

<pre>
@@default_text_area_height = 20
</pre>

This default class variable, and others, can be overridden by editing the file @config/initializers/formtastic.rb@ to remove the appropriate comment character (#) and assign a different default value. In this example, the number of displayed textarea lines has been changed from Formtastic's default of 20 to 5. 

<pre>
...

# Set the default text area height when input is a text. Default is 20.
Formtastic::SemanticFormBuilder.default_text_area_height = 5

# Should all fields be considered "required" by default?
# Defaults to true, see ValidationReflection notes below.
# Formtastic::SemanticFormBuilder.all_fields_required_by_default = true

...
</pre>

h4. Localization I18n

The fourth file, @config/locales/en.yml@ , is included in any standard Rails project build (e.g. rails MyProject). Starting with "Rails 2.2 an Internationalization (I18n)":http://guides.rubyonrails.org/i18n.html locale file ( @en.yml@ ) is created by the rails command.  Formtastic makes very good use of I18n as part of its standards and best practices objective. Formtastic's use of the I18n API for basic and enhanced localization is discussed in a separate section.  

h4. CSS

A proof-of-concept stylesheet @formtastic.css@ is installed by the generator script @./script/generate formtastic@. CSS customization is best achieved by overriding these styles in an additional stylesheet @formtastic_changes.css@. Following this convention allows the Formtastic stylesheet, formtastic.css, included as part of Formtastic gem, to be changed and updated with version releases without clobbering your changes in formtastic_changes.css.

These CSS asset files can be included in your rails layout file in a couple of ways. You can build your own complete list of css file assets:

<pre>
  <head>
    ...
    <%= stylesheet_link_tag "main", "formtastic", "formtastic_changes" %>
    ...
  </head>
</pre>

or you can use the formtastic formtastic_stylesheet_link_tag()  method in combination with any of your css file assets

<pre>
  <head>
    ...
    <%= stylesheet_link_tag "main" %>
    <%= formtastic_stylesheet_link_tag %>
    ...
  </head>
</pre>

Here's some further information about Rails "layouts and asset tags.":http://guides.rails.info/layouts_and_rendering.html#asset-tags 

Formtastic renders form inputs as ordered lists and the CSS styling applied to those lists focuses on the use of the CSS float property to a large extent. The reasons for both these design choices are covered in a separate section dedicated to Formtastic form styling.